package com.x.gateway;

import com.x.gateway.feign.FileFeginApi;
import com.x.gateway.feign.Hello;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
@RestController
public class GatewayApplication {
    @Autowired
    Hello hello;

    @Autowired
    private FileFeginApi fileFeginApi;

    @RequestMapping("/")
    public String hello() {
        System.out.println("===begin to call hello=== EurekaClient2Application");
        return "Hello World: " + hello.hello("Y") +" , returned to EurekaClient2Application";
    }

    @GetMapping("/download")
    public String getFileDownloadUrlById(@RequestParam Long id) {
        System.out.println("===begin to call getFileDownloadUrlById=== ");
        return fileFeginApi.getFileDownloadUrlById(id);
    }

    public static void main(String[] args) {
        SpringApplication.run(GatewayApplication.class, args);
    }
}
